def sumOfDigits(n):
    
    # 法一
    # s = str(n)
    # ans = 0
    # for i in s:
    #     ans += int(i)
    # return ans

    # 法二
    # return sum([int(i) for i in str(n)])

    # 法三
    # if n == 0:
    #     return 0
    # return n % 10 + sumOfDigits(n // 10)

    # 法四
    # ans = 0
    # while n > 0:
    #     ans += n % 10
    #     n //= 10
    # return ans 

    # 法五
    ans = 0
    while n > 0:
        x = divmod(n, 10) # (1234,5)
        # print(x)
        # print(x[1])
        ans += x[1]
        n = x[0]
    return ans 


test_cases = {
    12345: 15,
    234: 9,
    0: 0,
    1: 1,
    10: 1,
    13579: 25
}

ok = True
for test, exp in test_cases.items():
    if sumOfDigits(test) != exp:
        ok = False
        print("Test Failed {}, expected = {}".format(test, exp))

if ok:
    print("All passed")